<?php
require_once('../../config/maptrick.conf.php');
require_once(SITE_ROOT . "class/db/DBCountry.class.php");
require_once(SITE_ROOT . "class/graphs/HLeagueGraph.class.php");

ini_set("memory_limit", "100M");
ini_set("max_execution_time", 36000);

try {
	if ($_GET["pass"] != SCRIPT_PWD) die("Incorrect password");

	$dbcountry = new DBCountry();
	$countries = $dbcountry->getCountries("countryID");
	$hleagueGraph = new HLeagueGraph();
	$successcount = 0;
	foreach ($countries as $country) {
		$hleagueGraph->generateChart($country);
		$successcount++;
	}
	echo $successcount . " of " . count($countries) . " countries finished successfully<br />";
	$hleagueGraph->generateGlobalChart();
	echo "Global finished successfully<br />";
	echo "HLeague graph generation finished successfully";
	exit();
}
catch (Exception $e) {
	echo "HLeague graph generation failed";
	exit();
}

?>